﻿/*    
 *  PPMS整理
 *  功能：等级送礼
 * 
 */

var status = 0;
var bossid = "等级礼包";
var giftLevel = Array(30,60,100,140,180,220,250);
var giftContent = Array(
    //30
    Array(4005000, 6, 0),//力量水晶
	Array(4005001, 6, 0),//智慧水晶
	Array(4005002, 6, 0),//敏捷水晶
	Array(4005003, 6, 0),//幸运水晶	
	Array(4310234, 10, 0),//闪耀币	
	Array(4001839, 60, 0),//星星	
    Array(2433287, 200, 0),//咒语	
	Array(5062000, 3, 0),//神奇魔方		
	Array(2022457, 100, 0),//超级药水
	Array(2614000, 5, 0),//100%突破1万			
	//60
    Array(4005000, 9, 1),//力量水晶
	Array(4005001, 9, 1),//智慧水晶
	Array(4005002, 9, 1),//敏捷水晶
	Array(4005003, 9, 1),//幸运水晶	
	Array(4310234, 15, 1),//闪耀币	
	Array(4001839, 120, 1),//星星	
    Array(2433287, 400, 1),//咒语		
	Array(2049402, 3, 1),//附加潜能100%	
	Array(5062000, 6, 1),//神奇魔方		
	Array(2022457, 200, 1),//超级药水
	Array(2614000, 6, 1),//100%突破1万
	//100
    Array(4005000, 12, 2),//力量水晶
	Array(4005001, 12, 2),//智慧水晶
	Array(4005002, 12, 2),//敏捷水晶
	Array(4005003, 12, 2),//幸运水晶
	Array(4310234, 20, 2),//闪耀币	
	Array(4001839, 240, 2),//星星	
    Array(2433287, 600, 2),//咒语		
	Array(2048315, 6, 2),//附加附加潜能100%	
	Array(5062000, 9, 2),//神奇魔方		
	Array(2022457, 300, 2),//超级药水
	Array(2614000, 9, 2),//100%突破1万	
	Array(1003561, 1, 2),//风暴帽
	Array(1032148, 1, 2),//风暴耳环
	Array(1112748, 1, 2),//风暴戒指	
	Array(1152099, 1, 2),//风暴简章	
	Array(1082438, 1, 2),//风暴手套	
	Array(1122200, 1, 2),//风暴吊坠	
	Array(1052467, 1, 2),//风暴套服		
	Array(1132161, 1, 2),//风暴腰带		
	Array(1072672, 1, 2),//风暴鞋子			
	//140
    Array(4250801, 9, 3),//力量水晶
	Array(4250901, 9, 3),//智慧水晶
	Array(4251101, 9, 3),//敏捷水晶
	Array(4251001, 9, 3),//幸运水晶	
	Array(4310234, 25, 3),//闪耀币	
	Array(4001839, 480, 3),//星星	
    Array(2433287, 800, 3),//咒语		
	Array(2048713, 3, 3),//涅槃140
	Array(5062002, 9, 3),//神奇魔方		
	Array(2022457, 400, 3),//超级药水
	Array(2614045, 3, 3),//50%突破10万	
	Array(1113226, 1, 3),//至尊耳环	
	Array(1152192, 1, 3),//至尊项链	
	Array(1122336, 1, 3),//至尊戒指	
	Array(1162037, 1, 3),//至尊腰带	
	Array(1032258, 1, 3),//至尊腰带	
	Array(1182175, 1, 3),//至尊腰带		
	Array(1132294, 1, 3),//至尊腰带		
	//160
    Array(4250801, 12, 4),//力量水晶
	Array(4250901, 12, 4),//智慧水晶
	Array(4251101, 12, 4),//敏捷水晶
	Array(4251001, 12, 4),//幸运水晶
	Array(4310234, 30, 4),//闪耀币	
	Array(4001839, 960, 4),//星星	
    Array(2433287, 800, 4),//咒语		
	Array(3064220, 1, 4),//5%星岩攻击
	Array(3064230, 1, 4),//5%星岩魔法
	Array(5062009, 6, 4), //高级魔方	
	Array(2022457, 500, 4),//超级药水	
	Array(2614047, 6, 4),//30%突破50万		
	Array(1032220, 1, 4), //低级贝勒德耳环
	Array(1113072, 1, 4), //低级贝勒德戒指
	Array(1122264, 1, 4), //低级贝勒德刻印吊坠
	Array(1132243, 1, 4), //低级贝勒德刻印腰带
	//200
    Array(4250802, 6, 5),//力量水晶
	Array(4250902, 6, 5),//智慧水晶
	Array(4251102, 6, 5),//敏捷水晶
	Array(4251002, 6, 5),//幸运水晶			
	Array(4310234, 35, 5),//闪耀币		
	Array(4001839, 1920, 5),//星星	
	Array(2433287, 1000, 5),//咒语	
	Array(2049310, 2, 5), //5星强化	
	Array(5062009, 9, 5), //高级魔方
	Array(2022457, 600, 5),//超级药水	
	Array(2614047, 6, 5),//30%突破50万	
	Array(1022195, 1, 5), //超越证明	
	Array(1032201, 1, 5), //超越证明	
	Array(1122259, 1, 5), //超越证明	
	Array(1113056, 1, 5), //超越证明
	Array(1012414, 1, 5), //超越证明	
	//250级
    Array(4250802, 12, 6),//力量水晶
	Array(4250902, 12, 6),//智慧水晶
	Array(4251102, 12, 6),//敏捷水晶
	Array(4251002, 12, 6),//幸运水晶
	Array(4310234, 40, 6),//闪耀币		
	Array(4001839, 3840, 6),//星星	
	Array(2433287, 1200, 6),//咒语	
	Array(2049310, 2, 6), //5星强化	
	Array(5570000, 1, 6), //金锤子	
	Array(5064000, 1, 6), //防爆		
	Array(5062009, 12, 6), //高级魔方
	Array(2022457, 700, 6),//超级药水	
	Array(2614047, 6, 6),//30%突破50万	
	Array(1004637, 1, 6), //BOSS 9件套	
	Array(1132296, 1, 6), //BOSS 9件套	
	Array(1102871, 1, 6), //BOSS 9件套		
	Array(1012478, 1, 6), //BOSS 9件套
	Array(1022231, 1, 6), //BOSS 9件套	
	Array(1032136, 1, 6), //BOSS 9件套	
	Array(1113282, 1, 6), //BOSS 9件套	
	Array(1162025, 1, 6), //BOSS 9件套		
	Array(1152170, 1, 6), //BOSS 9件套	
	Array(1122375, 1, 6), //BOSS 9件套		
	Array(1182087, 1, 6), //BOSS 9件套			
          //230
      // Array(1122259, 1, 7),
        Array(2048723, 3, 7),
        Array(2431938, 1, 7),
        Array(2046996, 2, 7),
        Array(2046997, 2, 7),
        Array(2047818, 2, 7),
        Array(2612059, 2, 7),
        Array(5062010, 20, 7),
        Array(5062024, 20, 7),
	//240级
	Array(2432069, 1, 8),
        Array(2048723, 3, 8),
        Array(5062010, 20, 8),
        Array(5062024, 20, 8),
        Array(2046996, 2, 8),
        Array(2046997, 2, 8),
        Array(2047818, 2, 8),
        Array(2612059, 2, 8),
	Array(4000463, 10, 8), //黄金枫叶，兑换点卷使用
	Array(5062000, 10, 8),
	//Array(2300001, 300, 8),
	Array(5062002, 10, 8),
	Array(5062500, 10, 8),
	Array(5064000, 10, 8),
	Array(2431995, 1, 8), //惊人卷轴箱子
	Array(4310036, 3000, 8), //征服者
	Array(4033356, 10, 8), //正义火种1
	Array(4021010, 3, 8), //时间之石
	Array(4310015, 2, 8) //斗神证物
        /*
         2046996 - 惊人的单手武器攻击力卷轴100%
         2046997 - 惊人的单手武器魔力卷轴100%
         2047818 - 惊人的双手武器攻击力卷轴100%
         2612059 - 惊人的双手武器魔力卷轴100% 
         */
        );
var giftId = -1;
var giftToken = Array();
var gifts = null;
function start() {
    status = -1;
    action(1, 0, 0);
}

function action(mode, type, selection) {
    if (status == 0 && mode == 0) {
        cm.dispose();
        return;
    }
    if (mode == 1) {
        status++;
    } else {
        status--;
    }
    if (status == 0) {
        var text = "";
        text += "#e#rPPMS等级送礼\r\n#n这里根据您的等级作为领取条件,各类水晶可以制作装备,闪耀币可以兑换点装,不同礼包内赠送的套装及装备都并非一样！请保证您的背包所有栏目都有12格的空位否则无法领取！\r\n#n#b";
        for (var key in giftLevel) {
            var tips = "";
            giftToken[key] = false;
            if (cm.getChar().getLevel() >= giftLevel[key]) {
                if (cm.getPQLog(bossid + key, 1) == 0) {
                    tips = "可以领取！";
                    giftToken[key] = true;
                } else {
                    tips = "#g(您已领取)#b";
                }
            } else {
                tips = "#r您的等级不够无法领取！#b";
            }
            text += "#b#L" + (parseInt(key)) + "#领取#r#e" + giftLevel[key] + "#n#b 级等级礼包 " + tips + "#l#k\r\n";
        }
        cm.sendSimple(text);
    } else if (status == 1) {
        giftId = parseInt(selection);
        var text = "#r#ePPMS冒险岛·" + giftLevel[giftId] + "#n#b 级礼包内容：\r\n注意#v4310234# 可以通过拍卖——PPMS中介——闪耀币兑换点装！\r\n各类水晶可以找自由市场莫哈默德制作装备！\r\n";
        gifts = getGift(giftId);
        for (var key in gifts) {
            var itemId = gifts[key][0];
            var itemQuantity = gifts[key][1];
            text += "#v" + itemId + "##b#t" + itemId + "##k #rx " + itemQuantity + "#k\r\n";
        }
        text += "\r\n#d是否现在就领取该礼包？#k";
        cm.sendYesNo(text);
    } else if (status == 2) {
        if (giftId != -1 && gifts != null) {
            if (cm.getSpace(1) < 12 || cm.getSpace(2) < 12 || cm.getSpace(3) < 12 || cm.getSpace(4) < 12 || cm.getSpace(5) < 12) {
                cm.sendOk("您的背包空间不足，请保证每个栏位至少12格的空间，以避免领取失败。");
                cm.dispose();
                return;
            }
            var job = cm.getChar().getJob();
            if ((job == 10000 || job == 10100 || job == 10110 || job == 10111 || job == 10112) && cm.getChar().getLevel() < 140) {
                cm.sendOk("神之子需要到140才能领取！");
                cm.dispose();
                return;
            }
            if (giftToken[giftId] && cm.getPQLog(bossid + key, 1) == 0) {
                cm.setPQLog(bossid + (giftId), 1, 1);
                for (var key in gifts) {
                    var itemId = gifts[key][0];
                    var itemQuantity = gifts[key][1];
                    cm.gainItem(itemId, itemQuantity);
                }
                cm.sendOk("恭喜您，领取成功！快打开包裹看看吧！");
                cm.dispose();
            } else {
                status = -1;
                cm.sendSimple("您已经领过了该礼包或者等级未达到要求，无法领取。");
            }
        } else {
            cm.sendOk("领取错误！请联系管理员！");
            cm.dispose();
        }
    }
}
function getGift(id) {
    var lastGiftContent = Array();
    for (var key in giftContent) {
        if (giftContent[key][2] == id)
            lastGiftContent.push(giftContent[key]);
    }
    return lastGiftContent;
}